<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style>
        
    </style>
</head>
<body>
    
</body>
<script>
    
    // 非空字符，为true，空为false         
    console.log( Boolean( "hello" ) );        //true
    console.log( Boolean( "false" ) );       //true
    console.log( Boolean( " " ) );       //true
    console.log( Boolean( "" ) );       //false
    
    // 非0为true，0为false
    console.log( Boolean( 0 ) );       //false
    console.log( Boolean( 3 ) );       //true
    console.log( Boolean( -1 ) );       //true
    console.log( Boolean( -2.5 ) );       //true
    console.log( Boolean( 2.5 ) );       //true

    // undefined，null，NaN都是false
    console.log( Boolean( undefined ) );       //false
    console.log( Boolean( null ) );       //false
    console.log( Boolean( NaN ) );       //false

    // 函数，对象都是true 
    console.log( Boolean( function(){} ) );       //true
    console.log( Boolean( {name:"admin"} ) );       //true
    console.log( Boolean( {} ) );       //true
    console.log( Boolean( [] ) );       //true
    console.log( Boolean( [false] ) );       //true
    console.log( Boolean( [0] ) );       //true
    console.log( Boolean( [undefined] ) );       //true
    
</script>
</html>